package com.woniu.mgr.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.woniu.mgr.model.Coach;
import com.woniu.mgr.model.Comment;
import com.woniu.mgr.dao.CommentDao;
import com.woniu.mgr.service.CommentService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * <p>
 * 评论表 服务实现类
 * </p>
 *
 * @author Silas
 * @since 2023-02-15
 */
@Service
public class CommentServiceImpl extends ServiceImpl<CommentDao, Comment> implements CommentService {

    @Resource
    private CommentDao commentDao;
    @Override
    public IPage<Comment> list(Integer page, Integer size) {
        //分页查询
        Page<Comment> pages = new Page<>(page, size);
        QueryWrapper<Comment> wrapper = new QueryWrapper<>();
        Page<Comment> page1 = commentDao.selectPage(pages, wrapper);
        return page1;
    }

    @Override
    public List<Comment> query(Integer articleId) {
        List<Comment> comments = commentDao.selectList(new QueryWrapper<Comment>().eq("article_id", articleId));
        return comments;
    }
}
